<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // class Person{
        //     constructor(name,age){
        //         this.name = name
        //         this.age = age
        //     }
        //     fn(){
        //         console.log('fn');
        //     }
        // }

        // let zhangsan = new Person('张三',20)
        // console.log(zhangsan);


        // 属性多种定义方式
        // 支持 get 和 set
        class pr{
            constructor(){
                this.name = '张三'
            }
            fn(){
                console.log(this.name);
            }
            get age(){
                return 20
            }
            set age(val){
                console.log('??',val);
            }
        }
        let hh = new pr()
        hh.fn()
        hh.age = 30
        console.log(hh);
    </script>
</body>
</html>